package com.challenge.smsdao.dormitorymanage.domain;

import com.challenge.smsdao.studentmanage.domain.Student;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.challenge.smsbase.Domain.BaseEntity;

import javax.persistence.*;
import java.util.List;


/**
 * louzhiqiang
 */
@Entity
public class Dormitory extends BaseEntity<Long> {

    @Column
    private String name;
    @JsonIgnoreProperties("dormitories")
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "apartment_id")
    private Apartment apartment;

    @JsonIgnoreProperties("dormitory")
    @OneToMany(mappedBy = "dormitory",cascade = {CascadeType.REMOVE,CascadeType.REFRESH},fetch = FetchType.LAZY)
    private List<Student> students;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Apartment getApartment() {
        return apartment;
    }

    public void setApartment(Apartment apartment) {
        this.apartment = apartment;
    }

    public List<Student> getStudents() {
        return students;
    }

    public void setStudents(List<Student> students) {
        this.students = students;
    }
}

